package com.tao.ai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tao.ai.entity.User;
import com.tao.ai.mapper.UserMapper;
import com.tao.ai.mapper.UserStudentMapper;
import com.tao.ai.mapper.UserTeacherMapper;
import com.tao.ai.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private UserMapper usermapper;
    @Autowired
    private UserStudentMapper userStudentMapper;
    @Autowired
    private UserTeacherMapper userTeacherMapper;

    @Override
    public User findByName(String username) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("username",username);
        return usermapper.selectOne(wrapper);
    }

    @Override
    public Integer findByUserIdS(Integer userId) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("user_id",userId);
        return userStudentMapper.selectOne(wrapper).getStudentId();
    }

    @Override
    public Integer findByUserIdT(Integer userId) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("user_id",userId);
        return userTeacherMapper.selectOne(wrapper).getTeacherId();
    }
}
